{% extends "common/default.html" %}
{% block common %}
    <script type="text/javascript">
        // 录入成绩
        function update(id) {
            var score = $("#score_"+id).val();
            if (score == null || score == "") {
                alert("请输入成绩！");
                return;
            }
            $.post("../teacher/teacher_update", {id: id, score: score},
                function (result) {
                    //var result = eval('(' + result + ')');
                    if (result=="success") {
                        alert("执行成功！");
                        window.location.href = "../teacher/teacher_scoreInfo";
                    } else {
                        alert(result);
                    }
                }
            );
        }

    </script>
<div class="row search">
        <div class="col-md-6">
            <form action="../teacher_search" method="post">
                <div class="input-group" style="width: 300px">
                    <input type="text" class="form-control" name="content"
                           placeholder="请输入要查询的用户名...">
                    <span class="input-group-btn">
		        <button class="btn btn-default" type="submit"><span
                        class="glyphicon glyphicon-search"></span>&nbsp;查询</button>
		      </span>
                </div>
            </form>
        </div>
    <div>
        <table class="table table-hover  table-bordered table-striped" style="margin-bottom: 0px;">
            <tr>
                <th>序号</th>
                <th>学生姓名</th>
                <th>课程名称</th>
                <th>得分</th>
                <th>操作</th>
            </tr>
            {% for student_course in student_courses %}
                <tr>
                    <td>{{ student_course.id }}</td>
                    <td>{{ student_course.studentId.trueName }}</td>
                    <td>{{ student_course.courseId.courseName }}</td>

                    {% if student_course.score == None %}
                        <td>
                            <input type="text" id="score_{{ student_course.id }}" style="width: 50px;padding-left: 10px;"/></td>
                        <td>
                            <button type="button" class="btn btn-danger btn-xs" onclick="update({{student_course.id }})">
                                录入成绩
                            </button>
                        </td>
                    {% else %}
                        <td>
                            <input type="text" id="score_{{ student_course.id }}" style="width: 50px;padding-left: 10px;"
                                   value="{{student_course.score}}"/>
                        </td>
                        <td>
                            <button type="button" class="btn btn-info btn-xs" onclick="update({{student_course.id }})">
                                修改成绩
                            </button>
                        </td>
                    {% endif %}
                </tr>
            {% endfor %}
        </table>
    </div>
{% endblock %}



